From 001ae2365b033f3e1699bcbdb87b8d38b08d3421 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Wed, 1 Jan 2014 04:10:41 +0000 Subject: [PATCH] More pieces. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4691 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/bend.cc | 4 ++-- gpsbabel/mmo.cc | 26 ++++-------------------- gpsbabel/pcx.cc | 12 +++++------ gpsbabel/pocketfms_bc.cc | 4 ++-- gpsbabel/pocketfms_fp.cc | 44 ++-------------------------------------- gpsbabel/pocketfms_wp.cc | 4 ++-- gpsbabel/psitrex.cc | 16 +++++++-------- 7 files changed, 25 insertions(+), 85 deletions(-) diff --git a/gpsbabel/bend.cc b/gpsbabel/bend.cc index f77ac4a3c..ef7d58b91 100644 --- a/gpsbabel/bend.cc +++ b/gpsbabel/bend.cc @@ -175,8 +175,8 @@ static void process_route_orig(const route_head* route_orig) { route_head* route_dest = route_head_alloc(); - route_dest->rte_name = xstrdup(route_orig->rte_name); - route_dest->rte_desc = xstrdup(route_orig->rte_desc); + route_dest->rte_name = route_orig->rte_name; + route_dest->rte_desc = route_orig->rte_desc; route_dest->fs = fs_chain_copy(route_orig->fs); route_dest->rte_num = route_orig->rte_num; diff --git a/gpsbabel/mmo.cc b/gpsbabel/mmo.cc index b43a31332..b6b9e6b9d 100644 --- a/gpsbabel/mmo.cc +++ b/gpsbabel/mmo.cc @@ -461,11 +461,7 @@ mmo_read_CObjWaypoint(mmo_data_t* data) data->name, data->visible ? "yes" : "NO", data->objid)); data->data = wpt = waypt_new(); -#if NEW_STRINGS wpt->shortname = QString::fromLatin1(data->name); -#else - wpt->shortname = xstrdup(data->name); -#endif time = data->mtime; if (! time) { @@ -609,7 +605,7 @@ mmo_read_CObjRoute(mmo_data_t* data) data->name, data->visible ? "yes" : "NO", data->objid)); data->data = rte = route_head_alloc(); - rte->rte_name = xstrdup(data->name); + rte->rte_name = data->name; route_add_head(rte); if (mmo_version >= 0x18) { @@ -684,7 +680,7 @@ mmo_read_CObjTrack(mmo_data_t* data) data->name, data->visible ? "yes" : "NO", data->objid)); trk = route_head_alloc(); - trk->rte_name = xstrdup(data->name); + trk->rte_name = data->name; track_add_head(trk); if (mmo_version >= 0x18) { @@ -994,24 +990,10 @@ mmo_finalize_rtept_cb(const waypoint* wptref) wpt->latitude = wpt2->latitude; wpt->longitude = wpt2->longitude; -#if NEW_STRINGS wpt->shortname = (wpt2->shortname); -#else - xfree(wpt->shortname); - wpt->shortname = xstrdup(wpt2->shortname); -#endif -#if NEW_STRINGS - wpt->description = (wpt2->description); - wpt->notes = (wpt2->notes); -#else - if (wpt2->description) { - wpt->description = xstrdup(wpt2->description); - } - if (wpt2->notes) { - wpt->notes = xstrdup(wpt2->notes); - } -#endif + wpt->description = (wpt2->description); + wpt->notes = (wpt2->notes); if (wpt2->HasUrlLink()) { UrlLink l = wpt2->GetUrlLink(); wpt->notes = xstrdup(l.url_.toUtf8().data()); diff --git a/gpsbabel/pcx.cc b/gpsbabel/pcx.cc index c847ff458..8a72fc8c8 100644 --- a/gpsbabel/pcx.cc +++ b/gpsbabel/pcx.cc @@ -157,11 +157,11 @@ data_read(void) wpt_tmp->altitude = alt; cp = lrtrim(name); if (*cp != '\0') { - wpt_tmp->shortname = xstrdup(cp); + wpt_tmp->shortname = cp; } cp = lrtrim(desc); if (*cp != '\0') { - wpt_tmp->description = xstrdup(cp); + wpt_tmp->description = cp; } wpt_tmp->icon_descr = gt_find_desc_from_icon_number(symnum, PCX, NULL); @@ -202,11 +202,11 @@ data_read(void) if (track == NULL) { if (ibuf[3] == 'L' && ibuf[4] == 'A') { track = route_head_alloc(); - track->rte_name = xstrdup("track"); + track->rte_name = "track"; track_add_head(track); } else if (ibuf[3] == 'T' && ibuf[4] == 'N') { track = route_head_alloc(); - track->rte_name = xstrdup(&ibuf[6]); + track->rte_name = &ibuf[6]; track_add_head(track); } } @@ -217,7 +217,7 @@ data_read(void) n++; } route = route_head_alloc(); - route->rte_name = xstrdup(&ibuf[n]); + route->rte_name = &ibuf[n]; route_add_head(route); break; case 'T': @@ -266,7 +266,7 @@ data_read(void) /* Did we get a track point before a track header? */ if (track == NULL) { track = route_head_alloc(); - track->rte_name = xstrdup("Default"); + track->rte_name = "Default"; track_add_head(track); } track_add_wpt(track, wpt_tmp); diff --git a/gpsbabel/pocketfms_bc.cc b/gpsbabel/pocketfms_bc.cc index 9d9ada54d..fc1d4bcf9 100644 --- a/gpsbabel/pocketfms_bc.cc +++ b/gpsbabel/pocketfms_bc.cc @@ -83,8 +83,8 @@ read_tracks(void) struct breadcrumb bc; route_head* trk_head = route_head_alloc(); trk_head->rte_num = 1; - trk_head->rte_name = xstrdup("PocketFMS"); - trk_head->rte_desc = xstrdup("Breadcrumb"); + trk_head->rte_name = "PocketFMS"; + trk_head->rte_desc = "Breadcrumb"; trk_head->rte_url = "www.pocketfms.com"; track_add_head(trk_head); diff --git a/gpsbabel/pocketfms_fp.cc b/gpsbabel/pocketfms_fp.cc index c317ff22a..83d0bc5b1 100644 --- a/gpsbabel/pocketfms_fp.cc +++ b/gpsbabel/pocketfms_fp.cc @@ -68,19 +68,11 @@ rd_deinit(void) waypoint* head = (waypoint*) QUEUE_FIRST(&route->waypoint_list); waypoint* tail = (waypoint*) QUEUE_LAST(&route->waypoint_list); if (head != NULL) { - route->rte_name = xstrdup(head->shortname); + route->rte_name = head->shortname; } -#if NEW_STRINGS route->rte_name += " - "; -#else - route->rte_name = xstrappend(route->rte_name, " - "); -#endif if (tail != NULL) { -#if NEW_STRINGS route->rte_name += tail->shortname; -#else - route->rte_name = xstrappend(route->rte_name, tail->shortname); -#endif tail->altitude = dest_altitude; } } @@ -98,7 +90,7 @@ void wpt_s(xg_string args, const QXmlStreamAttributes* unused) if (isFirst == 1) { wpt_from = waypt_new(); route = route_head_alloc(); - route->rte_desc=xstrdup("PocketFMS flightplan"); + route->rte_desc="PocketFMS flightplan"; route_add_head(route); } wpt_to = waypt_new(); @@ -124,81 +116,49 @@ void wpt_e(xg_string args, const QXmlStreamAttributes* unused) void wpt_from_lat(xg_string args, const QXmlStreamAttributes* unused) { if (wpt_from != NULL) { -#if NEW_STRINGS wpt_from->latitude = args.toDouble(); -#else - wpt_from->latitude = atof(args); -#endif } } void wpt_from_lon(xg_string args, const QXmlStreamAttributes* unused) { if (wpt_from != NULL) { -#if NEW_STRINGS wpt_from->longitude = args.toDouble(); -#else - wpt_from->longitude = atof(args); -#endif } } void wpt_from_name(xg_string args, const QXmlStreamAttributes* unused) { if (wpt_from != NULL) { -#if NEW_STRINGS wpt_from->shortname += args; -#else - wpt_from->shortname = xstrappend(wpt_from->shortname, args); -#endif } } void wpt_from_elev(xg_string args, const QXmlStreamAttributes* unused) { if (wpt_from != NULL) { -#if NEW_STRINGS wpt_from->altitude = FEET_TO_METERS(args.toDouble()); -#else - wpt_from->altitude = FEET_TO_METERS(atof(args)); -#endif } } void wpt_to_lat(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_to->latitude = args.toDouble(); -#else - wpt_to->latitude = atof(args); -#endif } void wpt_to_lon(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_to->longitude = args.toDouble(); -#else - wpt_to->longitude = atof(args); -#endif } void wpt_to_name(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS wpt_to->shortname += args; -#else - wpt_to->shortname = xstrappend(wpt_to->shortname, args); -#endif } void wpt_to_elev(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS dest_altitude = FEET_TO_METERS(args.toDouble()); -#else - dest_altitude = FEET_TO_METERS(atof(args)); -#endif } void wpt_altitude(xg_string args, const QXmlStreamAttributes* attrv) diff --git a/gpsbabel/pocketfms_wp.cc b/gpsbabel/pocketfms_wp.cc index 279115485..2521f9220 100644 --- a/gpsbabel/pocketfms_wp.cc +++ b/gpsbabel/pocketfms_wp.cc @@ -71,7 +71,7 @@ data_read(void) if (!s) { fatal(MYNAME "Invalid name"); } - wpt->shortname = xstrdup(s); + wpt->shortname = s; s = csv_lineparse(NULL, "\\w", "", linecount); if (!s) { fatal(MYNAME "Invalid latitude %s", CSTRc(wpt->shortname)); @@ -126,7 +126,7 @@ enigma_waypt_disp(const waypoint* wpt) } *d = 0; } else { - t = xstrdup("NONAME"); + t = "NONAME"; } gbfprintf(file_out, "%s %f %f\n", t, wpt->latitude, wpt->longitude); xfree(t); diff --git a/gpsbabel/psitrex.cc b/gpsbabel/psitrex.cc index f7beaa434..bc5fdacb3 100644 --- a/gpsbabel/psitrex.cc +++ b/gpsbabel/psitrex.cc @@ -318,8 +318,8 @@ psit_waypoint_r(gbfile* psit_file, waypoint** wpt) /* the name */ psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); rtrim(psit_current_token); - thisWaypoint->shortname = xstrdup(psit_current_token); - thisWaypoint->description = xstrdup(""); + thisWaypoint->shortname = psit_current_token; + thisWaypoint->description = ""; psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL); rtrim(psit_current_token); @@ -411,7 +411,7 @@ psit_route_r(gbfile* psit_file, route_head** rte) rtrim(rtename); rte_head = route_head_alloc(); - rte_head->rte_name = xstrdup(rtename); + rte_head->rte_name = rtename; route_add_head(rte_head); *rte = rte_head; @@ -440,8 +440,8 @@ psit_route_r(gbfile* psit_file, route_head** rte) /* the name */ psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), comma); rtrim(psit_current_token); - thisWaypoint->shortname = xstrdup(psit_current_token); - thisWaypoint->description = xstrdup(""); + thisWaypoint->shortname = psit_current_token; + thisWaypoint->description = ""; psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL); rtrim(psit_current_token); @@ -539,7 +539,6 @@ psit_routehdr_w_wrapper(const route_head* rte) static void psit_track_r(gbfile* psit_file, route_head** trk) { - char tbuf[100]; char trkname[256]; unsigned int trk_num; @@ -612,10 +611,9 @@ psit_track_r(gbfile* psit_file, route_head** trk) tracklog is usually ACTIVE LOG the second is ACTIVE LOG001 and so on */ if (trk_num > 0) { - sprintf(tbuf, "%s%03d", trkname, trk_num); - track_head->rte_name = xstrdup(tbuf); + track_head->rte_name = QString().sprintf("%s%03d", trkname, trk_num); } else { - track_head->rte_name = xstrdup(trkname); + track_head->rte_name = trkname; } trk_num++; track_add_head(track_head); -- 2.30.2